import 'package:enterprise_v6_app/app/components/custom_app_bar.dart';
import 'package:enterprise_v6_app/app/components/organize_tree/emergency_department_tree.dart';
import 'package:enterprise_v6_app/app/components/process/closure_approval_process_widget.dart';
import 'package:enterprise_v6_app/app/core/core.dart';
import 'package:enterprise_v6_app/app/modules/application/emergency/common/drill_process/drill_process_view.dart';
import 'package:enterprise_v6_app/app/modules/application/emergency/drill/common/drill_common_widget.dart';
import 'package:enterprise_v6_app/app/modules/application/emergency/drill/drill_details/drill_details_controller.dart';
import 'package:enterprise_v6_app/app/modules/application/emergency/drill/drill_details/drill_results/drill_results_view.dart';

/// 演练详情页面
class DrillDetailsPage extends StatelessWidget {
  DrillDetailsPage({super.key});

  final controller = Get.put(DrillDetailsController());

  @override
  Widget build(BuildContext context) {
    return DefaultTabController(
      length: 4,
      child: GetBuilder(
          init: controller,
          builder: (_) {
            return Scaffold(
                appBar: CustomAppBar(titleText: controller.type == 1 ? '演练计划' : '演练记录'),
                body: Container(
                  color: const Color(0xffF5F5F6),
                  child: Column(
                    children: [
                      Container(
                        height: 54.w,
                        decoration: BoxDecoration(
                          color: Colors.white,
                          borderRadius: BorderRadius.circular(8.r),
                        ),
                        child: TabBar(
                          controller: controller.tabController,
                          tabs: controller.type == 1
                              ? const [
                                  Tab(text: '基本信息'),
                                  Tab(text: '演练人员'),
                                  Tab(text: '演练流程'),
                                  Tab(text: '审批流程'),
                                ]
                              : const [
                                  Tab(text: '基本信息'),
                                  Tab(text: '演练人员'),
                                  Tab(text: '演练流程'),
                                  Tab(text: '演练结果'),
                                ],
                          dividerColor: Colors.transparent,
                          labelPadding: EdgeInsets.only(bottom: 20.w),
                          labelStyle: TextStyle(
                            fontSize: 16.sp,
                            fontWeight: FontWeight.w500,
                          ),
                          unselectedLabelStyle: TextStyle(
                            fontSize: 16.sp,
                            fontWeight: FontWeight.w500,
                          ),
                          labelColor: Colors.black,
                          unselectedLabelColor: const Color(0xffA0A7B5),
                          indicatorPadding: EdgeInsets.only(top: 35.w, bottom: 10.w),
                          indicator: const BoxDecoration(
                            image: DecorationImage(
                              image: AssetImage(
                                'assets/images/icon_select_arc.png',
                              ),
                            ),
                          ),
                        ),
                      ),
                      Expanded(
                        child: Container(
                          padding: EdgeInsets.only(top: 14.w),
                          color: const Color(0xffF5F5F6),
                          child: TabBarView(
                            controller: controller.tabController,
                            children: controller.type == 1
                                ? [
                                    DrillPlanCommonWidget.getBasicInformationWidget(controller.entity),
                                    EmergencyDepartmentTree(businessId: controller.entity.emergencyId),
                                    DrillProcessPage(exercisePlanId: controller.id),
                                    ClosureApprovalProcessWidget(nodeList: controller.nodeList)
                                  ]
                                : [
                                    DrillPlanCommonWidget.getBasicInformationWidget(controller.entity),
                                    EmergencyDepartmentTree(businessId: controller.entity.emergencyId),
                                    DrillProcessPage(exercisePlanId: controller.id),
                                    DrillResultsPage(entity: controller.entity),
                                  ],
                          ),
                        ),
                      ),
                    ],
                  ),
                ));
          }),
    );
  }
}
